//
//  UIButton+Extension.swift
//  LYOnlineBanking
//
//  Created by 李永彬 on 2025/7/21.
//

import UIKit

extension UIButton {
    func setImageAndTitle(image: UIImage?, title: String, spacing: CGFloat) {
        self.setImage(image, for: .normal)
        self.setTitle(title, for: .normal)
        
        // 设置间距
        self.imageEdgeInsets = UIEdgeInsets(top: 0, left: -spacing/2, bottom: 0, right: spacing/2)
        self.titleEdgeInsets = UIEdgeInsets(top: 0, left: spacing/2, bottom: 0, right: -spacing/2)
        self.contentEdgeInsets = UIEdgeInsets(top: 0, left: spacing/2, bottom: 0, right: spacing/2)
        
        self.sizeToFit()
    }
}
